package com.sptpc.demo.service.impl;

import com.sptpc.demo.mapper.StudentMapper;
import com.sptpc.demo.model.Student;
import com.sptpc.demo.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService implements IStudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public List<Student> findAll() {
        return studentMapper.selectAll();
    }

    @Override
    public void delStudentByID(Long id) {
        studentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void newStudent(Student student) {
         studentMapper.insert(student);
    }

    @Override
    public void upDataStudent(Student student) {
        studentMapper.updateByPrimaryKey(student);
    }

    @Override
    public Student getStudentByID(Long id) {
        return studentMapper.selectByPrimaryKey(id);
    }
}
